package com.exmaple.dto;

import java.io.Serializable;

public class RpcResponse implements Serializable {

    private String requestId;

    private Boolean success = Boolean.TRUE;

    private String errInfo;

    private RpcRequest rpcRequest;

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getErrInfo() {
        return errInfo;
    }

    public void setErrInfo(String errInfo) {
        this.errInfo = errInfo;
    }

    public RpcRequest getRpcRequest() {
        return rpcRequest;
    }

    public void setRpcRequest(RpcRequest rpcRequest) {
        this.rpcRequest = rpcRequest;
    }

    public RpcResponse() {
    }

    public RpcResponse(RpcRequest rpcRequest) {
        this.rpcRequest = rpcRequest;
    }

    public static RpcResponse success() {
        return new RpcResponse();
    }

    public static RpcResponse error(String errInfo) {
        RpcResponse rpcResponse = new RpcResponse();
        rpcResponse.setSuccess(Boolean.FALSE);
        rpcResponse.setErrInfo(errInfo);
        return rpcResponse;
    }

    public static RpcResponse error(RpcRequest rpcRequest, String errInfo) {
        RpcResponse rpcResponse = new RpcResponse(rpcRequest);
        rpcResponse.setSuccess(Boolean.FALSE);
        rpcResponse.setErrInfo(errInfo);
        return rpcResponse;
    }
}
